package org.indt.scrum.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.indt.scrum.dao.ProgramaDAO;
import org.indt.scrum.model.Programa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;

public class ProgramaDAOImpl implements ProgramaDAO{

	private HibernateTemplate hibernateTemplate;

	@Autowired
	public ProgramaDAOImpl(SessionFactory sessionFactory) {
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
	}
	
	@Override
	public void delete(Programa entity) {
		this.hibernateTemplate.delete(entity);	
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Programa> listAll() {
		return this.hibernateTemplate.find("from Programa");
	}
	
	@Override
	public Programa load(Integer id) {
		return (Programa) this.hibernateTemplate.load(Programa.class, id);
	}
	
	@Override
	public void save(Programa entity) {
		this.hibernateTemplate.save(entity);
		
	}
	
	@Override
	public void update(Programa entity) {
		
		this.hibernateTemplate.update(entity);
	}

}
